|
|||||
|
This suite of programs provides an example of how to pass a parameter string from mainframe JCL to a COBOL program. The COBOL program is written using COBOL/2 dialect but also works with COBOL for MVS and COBOL/370. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows (refer to http://www.microfocus.com ). This program may serve as a tutorial for programmers that are new to COBOL and mainframe JCL and as a reference for experienced programmers.
The two techniques use to pass information (a Parameter) from JCL to a program are as follows.
| Technique | Description |
| via PARM= | This technique uses a PARM=parameter keyword on the EXEC statement in JCL. The COBOL program requires a LINKAGE SECTION. |
| via SYSIN | This technique requires SYSIN statement followed by the parameter to be placed in the JCL. The COBOL program requires an "ACCEPT parameter from SYSIN" to be coded in the COBOL program. If the SYSIN statement is missing in the JCL the ACCEPT will ABEND with a "File not found" message. To avoid this it will be necessary to use a "//SYSIN DD DUMMY" statment in the JCL when a parameter is not being passed. |
The following sections describe parameter-passing in more detail.
To pass a parameter from JCL to a program requires the use of the "PARM=" keyword with the EXEC statement. The following JCL statement shows an EXEC statement without a parameter defined.
The following is the mainframe JCL (CBLPARJ1.JCL) required to run as a job on the mainline. This will also run on the PC using Mainframe Express provided by Micro Focus. The job contains two steps. The first step will execute the COBOL program (CBLPARC1.CBL) without passing a parameter. The second step will execute the COBOL program and pass a parameter. The JOB statement will need to be modified for specific mainframe environments.
//CBLPARJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2003 All Rights Reserved * //* * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Process a parameter string passed from the JCL //* Author - SimoTime Enterprises //* Date - January 24, 1996 //* //* This is a sample program that shows how a COBOL program can //* process input from the JCL using the PARM keyword from the EXEC //* statement. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express //* //* ******************************************************************* //* Step 1 of 3, Execute the COBOL program without a parameter. //* //PARJ1S01 EXEC PGM=CBLPARC1 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //* //* ******************************************************************* //* Step 2 of 3, Execute the COBOL program with a parameter. //* //PARJ1S02 EXEC PGM=CBLPARC1, // PARM='This is a Parameter from the EXEC and PARM= ...' //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //* //* ******************************************************************* //* Step 3 of 3, Execute the COBOL program with a parameter. //* The PARM= has a record length maximum of 100. //* //PARJ1S03 EXEC PGM=CBLPARC1, // PARM='....:....1....:....2....:....3....:....4....:....5X // ....:....6....:....7....:....9....:...10....:...11' //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //*
This program (CBLPARC1.CBL) was written to be used as a teaching and learning aid. When a COBOL program is executed from a JCL member a data string (or parameter) may be passed from the JCL member to the COBOL program using the PARM keyword as follows.
//CBLPARS2 EXEC PGM=CBLPARC1,PARM='datastring'
When the data string is passed from JCL to COBOL it is preceded with a two-byte binary value that specifies the length of the data string. For example, if the data string is ten characters in length the actual information passed to the COBOL program would be a two-byte binary value of ten or x'000A' followed by the ten character data string. If the COBOL program is executed from JCL without a parameter the two-byte binary value would be zero or x'0000'.
IDENTIFICATION DIVISION.
PROGRAM-ID. CBLPARC1.
AUTHOR. SIMOTIME ENTERPRISES.
*****************************************************************
* Copyright (C) 1987-2003 SimoTime Enterprises, LLC. *
* *
* All rights reserved. Unpublished, all rights reserved under *
* copyright law and international treaty. Use of a copyright *
* notice is precautionary only and does not imply publication *
* or disclosure. *
* *
* Permission to use, copy, modify and distribute this software *
* for any non-commercial purpose and without fee is hereby *
* granted, provided the SimoTime copyright notice appear on all *
* copies of the software. The SimoTime name or Logo may not be *
* used in any advertising or publicity pertaining to the use *
* of the software without the written permission of SimoTime *
* Enterprises.This software contains confidential information *
* *
* Permission to use, copy, modify and distribute this software *
* for any commercial purpose requires a fee to be paid to *
* Simotime Enterprises. Once the fee is received by SimoTime *
* the latest version of the software will be delivered and a *
* license will be granted for use within an enterprise, *
* provided the SimoTime copyright notice appear on all copies *
* of the software. The SimoTime name or Logo may not be used *
* in any advertising or publicity pertaining to the use of the *
* software without the written permission of SimoTime *
* Enterprises. *
* *
* SimoTime Enterprises makes no warranty or representations *
* about the suitability of the software for any purpose. It is *
* provided "AS IS" without any express or implied warranty, *
* including the implied warranties of merchantability, fitness *
* for a particular purpose and non-infringement. SimoTime *
* Enterprises shall not be liable for any direct, indirect, *
* special or consequential damages resulting from the loss of *
* use, data or projects, whether in an action of contract or *
* tort, arising out of or in connection with the use or *
* performance of this software *
* *
* SimoTime Enterprises *
* 15 Carnoustie Drive *
* Novato, CA 94949-5849 *
* 415.883.6565 *
* *
* RESTRICTED RIGHTS LEGEND *
* Use, duplication, or disclosure by the Government is subject *
* to restrictions as set forth in subparagraph (c)(1)(ii) of *
* the Rights in Technical Data and Computer Software clause at *
* DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of *
* Commercial Computer Software - Restricted Rights at 48 *
* CFR 52.227-19, as applicable. Contact SimoTime Enterprises, *
* 15 Carnoustie Drive, Novato, CA 94949-5849. *
* *
*****************************************************************
* This program is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
*****************************************************************
*
*****************************************************************
* Source Member: CBLPARC1.CBL
*****************************************************************
*
* CBLPARC1 - This program will process a JCL parameter.
*
* CALLING PROTOCOL
* ----------------
* USE STANDARD PROCEDURE TO EXECUTE, RUN OR ANIMATE.
*
* DESCRIPTION
* -----------
* This program will process the JCL parameter from the PARM
* keyword of the EXEC staement.
*
* // EXEC PGM=PROGNAME,PARM='text string...'
*
* This program will simply display the text string.
*
****************************************************************
*
* MAINTENANCE
* -----------
* 1997/02/27 Simmons, Created program.
*
*****************************************************************
*
DATA DIVISION.
WORKING-STORAGE SECTION.
*
*****************************************************************
* Data-structure for Title and Copyright...
* ------------------------------------------------------------
01 SIM-TITLE.
05 T1 pic X(11) value '* CBLPARC1 '.
05 T2 pic X(34) value 'Sample, Process a JCL Parameter '.
05 T3 pic X(10) value ' v03.01.24'.
05 T4 pic X(24) value ' http://www.simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* CBLPARC1 '.
05 C2 pic X(20) value 'Copyright 1987-2003 '.
05 C3 pic X(28) value ' SimoTime Enterprises, LLC '.
05 C4 pic X(20) value ' All Rights Reserved'.
01 SIM-THANKS-01.
05 C1 pic X(11) value '* CBLPARC1 '.
05 C2 pic X(32) value 'Thank you for using this sample '.
05 C3 pic X(32) value 'by SimoTime Enterprises, LLC '.
05 C4 pic X(04) value ' '.
01 SIM-THANKS-02.
05 C1 pic X(11) value '* CBLPARC1 '.
05 C2 pic X(32) value 'Please send comments or suggesti'.
05 C3 pic X(32) value 'ons to helpdesk@simotime.com '.
05 C4 pic X(04) value ' '.
01 FIRST-TIME pic X value 'Y'.
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(11) value '* CBLPARC1 '.
05 MESSAGE-TEXT pic X(128).
01 MESSAGE-TEXT-01.
05 filler pic X(20) value 'Parameter length is '.
05 JCL-PARM-LENGTH pic 9(5) value 0.
*****************************************************************
LINKAGE SECTION.
01 PARM-BUFFER.
05 PARM-LENGTH pic S9(4) comp.
05 PARM-DATA pic X(256).
*****************************************************************
PROCEDURE DIVISION using PARM-BUFFER.
if FIRST-TIME not = 'N'
perform Z-POST-COPYRIGHT
move 'N' to FIRST-TIME
end-if
add PARM-LENGTH to ZERO giving JCL-PARM-LENGTH
move MESSAGE-TEXT-01 to MESSAGE-TEXT
perform Z-POST-MESSAGE
if PARM-LENGTH > 0
move PARM-DATA(1:PARM-LENGTH) to MESSAGE-TEXT
perform Z-POST-MESSAGE
end-if
perform Z-THANK-YOU.
GOBACK.
*****************************************************************
* Display Copyright or Program Messages...
*****************************************************************
Z-POST-COPYRIGHT.
display SIM-TITLE upon console
display SIM-COPYRIGHT upon console
exit.
*****************************************************************
Z-POST-MESSAGE.
display MESSAGE-BUFFER upon console
move SPACES to MESSAGE-TEXT
exit.
*****************************************************************
Z-THANK-YOU.
display SIM-THANKS-01 upon console
display SIM-THANKS-02 upon console
exit.
*****************************************************************
* This example is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
To pass a parameter from SYSIN to a program requires the use of DD statement for SYSIN. The following JCL statement is required if no parameter is passed.
//* ******************************************************************* //* Step 1 of 2, Execute the COBOL program without a parameter. //* //SYSIN DD DUMMY
The following is the mainframe JCL (CBLPARJ2.JCL) required to run as a job on the mainline. This will also run on the PC using Mainframe Express provided by Micro Focus. The job contains two steps. The first step will execute the COBOL program (CBLPARC2.CBL) without passing a parameter. The second step will execute the COBOL program and pass a parameter. The JOB statement will need to be modified for specific mainframe environments.
//CBLPARJ2 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2003 All Rights Reserved * //* * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Process a parameter string passed from the JCL //* Author - SimoTime Enterprises //* Date - January 24, 1996 //* //* This is a sample program that shows how a COBOL program can //* process input from the JCL using SYSIN. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express //* //* ******************************************************************* //* Step 1 of 2, Execute the COBOL program without a parameter. //* //* The //SYSIN DD DUMMY is required to prevent the COBOL //* program from ABENDING on the ACCEPT ... from SYSIN. //* //PARJ2S01 EXEC PGM=CBLPARC2 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //SYSIN DD DUMMY //* //* ******************************************************************* //* Step 2 of 2, Execute the COBOL program with a parameter. //* //PARJ2S02 EXEC PGM=CBLPARC2 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //SYSIN DD * This is a single parameter from PARJ2S02 and SYSIN-DD-* ... /* //* //
The following is the COBOL program (CBLPARC2.CBL) required to run as a job on the mainline. This will also run on the PC using Mainframe Express provided by Micro Focus. The job contains two steps. The first step will execute the COBOL program (CBLPARC2.CBL) without passing a parameter. The second step will execute the COBOL program and pass a parameter via SYSIN. The JOB statement will need to be modified for specific mainframe environments.
IDENTIFICATION DIVISION.
PROGRAM-ID. CBLPARC2.
AUTHOR. SIMOTIME ENTERPRISES.
*****************************************************************
* Copyright (C) 1987-2003 SimoTime Enterprises, LLC. *
* *
* All rights reserved. Unpublished, all rights reserved under *
* copyright law and international treaty. Use of a copyright *
* notice is precautionary only and does not imply publication *
* or disclosure. *
* *
* Permission to use, copy, modify and distribute this software *
* for any non-commercial purpose and without fee is hereby *
* granted, provided the SimoTime copyright notice appear on all *
* copies of the software. The SimoTime name or Logo may not be *
* used in any advertising or publicity pertaining to the use *
* of the software without the written permission of SimoTime *
* Enterprises.This software contains confidential information *
* *
* Permission to use, copy, modify and distribute this software *
* for any commercial purpose requires a fee to be paid to *
* Simotime Enterprises. Once the fee is received by SimoTime *
* the latest version of the software will be delivered and a *
* license will be granted for use within an enterprise, *
* provided the SimoTime copyright notice appear on all copies *
* of the software. The SimoTime name or Logo may not be used *
* in any advertising or publicity pertaining to the use of the *
* software without the written permission of SimoTime *
* Enterprises. *
* *
* SimoTime Enterprises makes no warranty or representations *
* about the suitability of the software for any purpose. It is *
* provided "AS IS" without any express or implied warranty, *
* including the implied warranties of merchantability, fitness *
* for a particular purpose and non-infringement. SimoTime *
* Enterprises shall not be liable for any direct, indirect, *
* special or consequential damages resulting from the loss of *
* use, data or projects, whether in an action of contract or *
* tort, arising out of or in connection with the use or *
* performance of this software *
* *
* SimoTime Enterprises *
* 15 Carnoustie Drive *
* Novato, CA 94949-5849 *
* 415.883.6565 *
* *
* RESTRICTED RIGHTS LEGEND *
* Use, duplication, or disclosure by the Government is subject *
* to restrictions as set forth in subparagraph (c)(1)(ii) of *
* the Rights in Technical Data and Computer Software clause at *
* DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of *
* Commercial Computer Software - Restricted Rights at 48 *
* CFR 52.227-19, as applicable. Contact SimoTime Enterprises, *
* 15 Carnoustie Drive, Novato, CA 94949-5849. *
* *
*****************************************************************
* This program is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
*****************************************************************
*
*****************************************************************
* Source Member: CBLPARC2.CBL
*****************************************************************
*
* CBLPARC2 - This program will process a SYSIN parameter.
*
* CALLING PROTOCOL
* ----------------
* USE STANDARD PROCEDURE TO EXECUTE, RUN OR ANIMATE.
*
* DESCRIPTION
* -----------
* This program will process the JCL parameter from SYSIN.
*
* //SYSIN DD *
* Parameter from SYSIN...
* //*
*
* or a DUMMY is required to avoid an ABEND on the ACCEPT...
*
* //SYSIN DD DUMMY
*
* This program will simply display the text string.
*
****************************************************************
*
* MAINTENANCE
* -----------
* 1997/02/27 Simmons, Created program.
*
*****************************************************************
*
DATA DIVISION.
WORKING-STORAGE SECTION.
*
*****************************************************************
* Data-structure for Title and Copyright...
* ------------------------------------------------------------
01 SIM-TITLE.
05 T1 pic X(11) value '* CBLPARC2 '.
05 T2 pic X(34) value 'Sample, Process SYSIN Parameter '.
05 T3 pic X(10) value ' v03.01.24'.
05 T4 pic X(24) value ' http://www.simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* CBLPARC2 '.
05 C2 pic X(20) value 'Copyright 1987-2003 '.
05 C3 pic X(28) value ' SimoTime Enterprises, LLC '.
05 C4 pic X(20) value ' All Rights Reserved'.
01 SIM-THANKS-01.
05 C1 pic X(11) value '* CBLPARC2 '.
05 C2 pic X(32) value 'Thank you for using this sample '.
05 C3 pic X(32) value 'by SimoTime Enterprises, LLC '.
05 C4 pic X(04) value ' '.
01 SIM-THANKS-02.
05 C1 pic X(11) value '* CBLPARC2 '.
05 C2 pic X(32) value 'Please send comments or suggesti'.
05 C3 pic X(32) value 'ons to helpdesk@simotime.com '.
05 C4 pic X(04) value ' '.
01 FIRST-TIME pic X value 'Y'.
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(11) value '* CBLPARC2 '.
05 MESSAGE-TEXT pic X(128).
01 MESSAGE-TEXT-01.
05 filler pic X(20) value 'Parameter length is '.
05 JCL-PARM-LENGTH pic 9(5) value 0.
01 SYSIN-PARAMETER pic X(80) value SPACES.
01 SYSIN-LENGTH pic 9(5) value 0.
01 IX-1 pic 9(3) value 0.
*****************************************************************
PROCEDURE DIVISION.
if FIRST-TIME not = 'N'
perform Z-POST-COPYRIGHT
move 'N' to FIRST-TIME
*> A DD statement is required or a hard ABEND will occur
*> on the ACCEPT. If no parameters are passed then a
*> //SYSIN DD DUMMY is required to prevent the COBOL
*> program from ABENDING on the ACCEPT ... from SYSIN.
accept SYSIN-PARAMETER from SYSIN
end-if
subtract SYSIN-LENGTH from SYSIN-LENGTH
if SYSIN-PARAMETER = SPACES
add SYSIN-LENGTH to ZERO giving JCL-PARM-LENGTH
move MESSAGE-TEXT-01 to MESSAGE-TEXT
perform Z-POST-MESSAGE
else
perform CALCULATE-TEXT-LENGTH
add SYSIN-LENGTH to ZERO giving JCL-PARM-LENGTH
move MESSAGE-TEXT-01 to MESSAGE-TEXT
perform Z-POST-MESSAGE
move SYSIN-PARAMETER to MESSAGE-TEXT
perform Z-POST-MESSAGE
end-if
perform Z-THANK-YOU.
GOBACK.
*****************************************************************
CALCULATE-TEXT-LENGTH.
add 1 to ZERO giving IX-1
perform 80 times
if SYSIN-PARAMETER(IX-1:1) not = SPACE
add IX-1 to ZERO giving SYSIN-LENGTH
end-if
add 1 to IX-1
end-perform
exit.
*****************************************************************
* Display Copyright or Program Messages...
*****************************************************************
Z-POST-COPYRIGHT.
display SIM-TITLE upon console
display SIM-COPYRIGHT upon console
exit.
*****************************************************************
Z-POST-MESSAGE.
display MESSAGE-BUFFER upon console
move SPACES to MESSAGE-TEXT
exit.
*****************************************************************
Z-THANK-YOU.
display SIM-THANKS-01 upon console
display SIM-THANKS-02 upon console
exit.
*****************************************************************
* This example is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
To pass multiple parameters (or records) from SYSIN to a program requires the use of DD statement for SYSIN. The following JCL statement is required if no parameter is passed.
//* ******************************************************************* //* Step 1 of 2, Execute the COBOL program without a parameter. //* //SYSIN DD DUMMY
The following is the mainframe JCL (CBLPARJ3.JCL) required to run as a job on the mainline. This will also run on the PC using Mainframe Express provided by Micro Focus. The job contains two steps. The first step will execute the COBOL program (CBLPARC3CBL) without passing a parameter. The second step will execute the COBOL program and pass provide three parameters. The JOB statement will need to be modified for specific mainframe environments.
//CBLPARJ3 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2003 All Rights Reserved * //* * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Process a parameter string passed from the JCL //* Author - SimoTime Enterprises //* Date - January 24, 1996 //* //* This is a sample program that shows how a COBOL program can //* process input from the JCL using SYSIN. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express //* //* ******************************************************************* //* Step 1 of 3, Execute the COBOL program without a parameter. //* //* The //SYSIN DD DUMMY is required to prevent the COBOL //* program from ABENDING on the ACCEPT ... from SYSIN. //* //PARJ3S01 EXEC PGM=CBLPARC3 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //SYSIN DD DUMMY //* //* ******************************************************************* //* Step 2 of 3, Execute the COBOL program with multiple parameters. //* //PARJ3S02 EXEC PGM=CBLPARC3 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //SYSIN DD * This is Parameter 01 from PARJ3S02 and SYSIN-DD-*. This is Parameter 02 from PARJ3S02 and SYSIN-DD-*.. This is Parameter 03 from PARJ3S02 and SYSIN-DD-*... /* //* //* ******************************************************************* //* Step 3 of 3, Execute the COBOL program with control file. //* //PARJ3S03 EXEC PGM=CBLPARC3 //STEPLIB DD DISP=SHR,DSN=SIMOTIME.DEMO.LOADLIB1 //SYSIN DD DISP=SHR,DSN=SIMOTIME.DEMO.CNTLDECK(CBLPARS3) //* //
In the preceding JCL example Step 3 of 3 passes parameters from a SYSIN Data Set (SIMOTIME.DEMO.CNTLDECK(CBLPARS3)) to the COBOL program. The SYSIN data set includes the following records.
Parameter 01 from control file specified by SYSIN-DD-CBLPARS3. Parameter 02 from control file specified by SYSIN-DD-CBLPARS3.. Parameter 03 from control file specified by SYSIN-DD-CBLPARS3...
The following is the COBOL program (CBLPARC3.CBL) required to run as a job on the mainline. This will also run on the PC using Mainframe Express provided by Micro Focus. The job contains two steps. The first step will execute the COBOL program (CBLPARC3.CBL) without passing a parameter. The second step will execute the COBOL program and pass a parameter via SYSIN. The JOB statement will need to be modified for specific mainframe environments.
IDENTIFICATION DIVISION.
PROGRAM-ID. CBLPARC3.
AUTHOR. SIMOTIME ENTERPRISES.
*****************************************************************
* Copyright (C) 1987-2003 SimoTime Enterprises, LLC. *
* *
* All rights reserved. Unpublished, all rights reserved under *
* copyright law and international treaty. Use of a copyright *
* notice is precautionary only and does not imply publication *
* or disclosure. *
* *
* Permission to use, copy, modify and distribute this software *
* for any non-commercial purpose and without fee is hereby *
* granted, provided the SimoTime copyright notice appear on all *
* copies of the software. The SimoTime name or Logo may not be *
* used in any advertising or publicity pertaining to the use *
* of the software without the written permission of SimoTime *
* Enterprises.This software contains confidential information *
* *
* Permission to use, copy, modify and distribute this software *
* for any commercial purpose requires a fee to be paid to *
* Simotime Enterprises. Once the fee is received by SimoTime *
* the latest version of the software will be delivered and a *
* license will be granted for use within an enterprise, *
* provided the SimoTime copyright notice appear on all copies *
* of the software. The SimoTime name or Logo may not be used *
* in any advertising or publicity pertaining to the use of the *
* software without the written permission of SimoTime *
* Enterprises. *
* *
* SimoTime Enterprises makes no warranty or representations *
* about the suitability of the software for any purpose. It is *
* provided "AS IS" without any express or implied warranty, *
* including the implied warranties of merchantability, fitness *
* for a particular purpose and non-infringement. SimoTime *
* Enterprises shall not be liable for any direct, indirect, *
* special or consequential damages resulting from the loss of *
* use, data or projects, whether in an action of contract or *
* tort, arising out of or in connection with the use or *
* performance of this software *
* *
* SimoTime Enterprises *
* 15 Carnoustie Drive *
* Novato, CA 94949-5849 *
* 415.883.6565 *
* *
* RESTRICTED RIGHTS LEGEND *
* Use, duplication, or disclosure by the Government is subject *
* to restrictions as set forth in subparagraph (c)(1)(ii) of *
* the Rights in Technical Data and Computer Software clause at *
* DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of *
* Commercial Computer Software - Restricted Rights at 48 *
* CFR 52.227-19, as applicable. Contact SimoTime Enterprises, *
* 15 Carnoustie Drive, Novato, CA 94949-5849. *
* *
*****************************************************************
* This program is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
*****************************************************************
*
*****************************************************************
* Source Member: CBLPARC3.CBL
*****************************************************************
*
* CBLPARC3 - This program will process a SYSIN parameter.
*
* CALLING PROTOCOL
* ----------------
* USE STANDARD PROCEDURE TO EXECUTE, RUN OR ANIMATE.
*
* DESCRIPTION
* -----------
* This program will process the JCL parameter from SYSIN.
*
* //SYSIN DD *
* Parameter from SYSIN...
* //*
*
* or a DUMMY is required to avoid an ABEND on the ACCEPT...
*
* //SYSIN DD DUMMY
*
* This program will simply display the text string.
*
****************************************************************
*
* MAINTENANCE
* -----------
* 1997/02/27 Simmons, Created program.
*
*****************************************************************
*
DATA DIVISION.
WORKING-STORAGE SECTION.
*
*****************************************************************
* Data-structure for Title and Copyright...
* ------------------------------------------------------------
01 SIM-TITLE.
05 T1 pic X(11) value '* CBLPARC3 '.
05 T2 pic X(34) value 'Sample, Process SYSIN Parameter '.
05 T3 pic X(10) value ' v03.04.22'.
05 T4 pic X(24) value ' http://www.simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* CBLPARC3 '.
05 C2 pic X(20) value 'Copyright 1987-2003 '.
05 C3 pic X(28) value ' SimoTime Enterprises, LLC '.
05 C4 pic X(20) value ' All Rights Reserved'.
01 SIM-THANKS-01.
05 C1 pic X(11) value '* CBLPARC3 '.
05 C2 pic X(32) value 'Thank you for using this sample '.
05 C3 pic X(32) value 'by SimoTime Enterprises, LLC '.
05 C4 pic X(04) value ' '.
01 SIM-THANKS-02.
05 C1 pic X(11) value '* CBLPARC3 '.
05 C2 pic X(32) value 'Please send comments or suggesti'.
05 C3 pic X(32) value 'ons to helpdesk@simotime.com '.
05 C4 pic X(04) value ' '.
01 FIRST-TIME pic X value 'Y'.
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(11) value '* CBLPARC3 '.
05 MESSAGE-TEXT pic X(128).
01 MESSAGE-TEXT-01.
05 filler pic X(20) value 'Parameter length is '.
05 JCL-PARM-LENGTH pic 9(5) value 0.
01 SYSIN-PARAMETER pic X(80) value SPACES.
01 SYSIN-LENGTH pic 9(5) value 0.
01 IX-1 pic 9(3) value 0.
COPY PASSDUMP.
*****************************************************************
PROCEDURE DIVISION.
if FIRST-TIME not = 'N'
perform Z-POST-COPYRIGHT
move 'N' to FIRST-TIME
end-if
perform 4 times
move SPACES to SYSIN-PARAMETER
*> A DD statement is required or a hard ABEND will occur
*> on the ACCEPT. If no parameters are passed then a
*> //SYSIN DD DUMMY is required to prevent the COBOL
*> program from ABENDING on the ACCEPT ... from SYSIN.
*> Since there is no File Status code for the accept then
*> an ACCEPT after the final record is read from SYSIN
*> will leave the buffer in the state before the request.
*> In this example the buffer is always initialized with
*> space characters and the logic in the program will
*> determine a ZERO record length and the routine should
*> stop accepting (or reading) from SYSIN. The following
*> example intentionally reads (or accepts) beyond the
*> SYSIN records available to show a technique for
*> handling this possibility.
accept SYSIN-PARAMETER from SYSIN
subtract SYSIN-LENGTH from SYSIN-LENGTH
if SYSIN-PARAMETER = SPACES
add SYSIN-LENGTH to ZERO giving JCL-PARM-LENGTH
move MESSAGE-TEXT-01 to MESSAGE-TEXT
perform Z-POST-MESSAGE
else
perform CALCULATE-TEXT-LENGTH
add SYSIN-LENGTH to ZERO giving JCL-PARM-LENGTH
move MESSAGE-TEXT-01 to MESSAGE-TEXT
perform Z-POST-MESSAGE
move SYSIN-PARAMETER to MESSAGE-TEXT
perform Z-POST-MESSAGE
end-if
end-perform
perform Z-THANK-YOU.
GOBACK.
*****************************************************************
CALCULATE-TEXT-LENGTH.
add 1 to ZERO giving IX-1
inspect SYSIN-PARAMETER replacing all LOW-VALUES by SPACES
perform 80 times
if SYSIN-PARAMETER(IX-1:1) not = SPACE
add IX-1 to ZERO giving SYSIN-LENGTH
end-if
add 1 to IX-1
end-perform
exit.
*****************************************************************
* Display Copyright or Program Messages...
*****************************************************************
Z-POST-COPYRIGHT.
display SIM-TITLE upon console
display SIM-COPYRIGHT upon console
exit.
*****************************************************************
Z-POST-MESSAGE.
display MESSAGE-BUFFER upon console
move SPACES to MESSAGE-TEXT
exit.
*****************************************************************
Z-THANK-YOU.
display SIM-THANKS-01 upon console
display SIM-THANKS-02 upon console
exit.
*****************************************************************
* This example is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
The purpose of this document is to assist as a tutorial for new programmers or as a quick reference for experienced programmers. These sample programs are made available on an "as-is" basis and may be downloaded, copied and modified for specific situations as long as the copyright information is not removed or changed. As always, it is the programmer's responsibility to thoroughly test all programs.
Permission to use, copy, modify and distribute this software for any commercial purpose requires a fee to be paid to Simotime Enterprises. Once the fee is received by SimoTime the latest version of the software will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
Permission to use, copy, modify and distribute this software for a non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com
You may download this example at http://www.simotime.com/sim4dzip.htm#COBOLJCLParameter as a Z-Pack. The Z-Packs provide individual programming examples, documentation and test data files in a single package. The Z-Packs are usually in zip format to reduce the amount of time to download.
Please view the complete list of SimoTime Z-Pack Examples at http://www.simotime.com/sim4dzip.htm .
Note: You must be attached to the Internet to download a Z-Pack or view the list.
Check out The JCL Connection in the SimoTime Library for more mainframe JCL examples. Also, take a look at a specific example of parameter passing and conditional processing with JCL.
Check out The COBOL Connection in the SimoTime Library for more examples of mainframe COBOL techniques and sample code.
The Pass, Parse and Convert Data Strings has examples of using COBOL for passing a parameter from JCL to COBOL plus other translation and parsing routines.
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com .
Founded in 1987, SimoTime Enterprises is a privately owned, Limited Liability Corporation located in Novato, California. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complimentary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
| Return-to-Top |
| Copyright © 1987-2005 SimoTime Enterprises, LLC All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |